﻿using System;

class FibonacciSequence
{
    static void Main()
    {
        Console.Write("Enter the length N (N > 3) of the sequence of Fibonacci (0, 1, 1): ");
        string consoleInput = Console.ReadLine();
        int n = 0;
        bool isValidInteger = int.TryParse(consoleInput, out n);
        long previous = 0;  // First member
        long current = 1;   // Second member
        long next = 1;      // Third member
        long sum = 2;       // Sum of the first three members
        if (isValidInteger && (n > 3))
        {
            Console.Write("The sum of the first [{0}] members of the sequence of Fibonacci is: 0 + 1 + 1", n);
            for (int i = 4; i <= n; i++)
            {
                previous = current;
                current = next;
                next = previous + current;
                sum += next;
                Console.Write(" + {0}", next);
            }
            Console.Write(" = " + sum);
            Console.WriteLine();
        }
        else
        {
            Console.WriteLine("Invalid value!");
        }
    }
}
